package cn.tedu.spring.bean;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    @Value("范传奇")
    private String username;
    @Value("123456")
    private String password;
    //对象或者接口类型，无法使用Value进行注入，需要使用@AutoWired进行注入
    // 可添加位置：属性，set方法，构造方法
    @Autowired
    private UserDao userDao;

    @Autowired
    public UserService(UserDao userDao) {
        System.out.println("UserService()...");
        this.userDao = userDao;
    }

    @Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public String toString() {
        return "UserService{" +
                "username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", userDao=" + userDao +
                '}';
    }
}
